home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / usr / lib / mozilla-firefox / include / layout / nsIMenuParent.h < prev    next >
C/C++ Source or Header  |  2006-05-08  |  7KB  |  180 lines

  1. /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. /* ***** BEGIN LICENSE BLOCK *****
  3.  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  4.  *
  5.  * The contents of this file are subject to the Mozilla Public License Version
  6.  * 1.1 (the "License"); you may not use this file except in compliance with
  7.  * the License. You may obtain a copy of the License at
  8.  * http://www.mozilla.org/MPL/
  9.  *
  10.  * Software distributed under the License is distributed on an "AS IS" basis,
  11.  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  12.  * for the specific language governing rights and limitations under the
  13.  * License.
  14.  *
  15.  * The Original Code is Mozilla Communicator client code.
  16.  *
  17.  * The Initial Developer of the Original Code is
  18.  * Netscape Communications Corporation.
  19.  * Portions created by the Initial Developer are Copyright (C) 1998
  20.  * the Initial Developer. All Rights Reserved.
  21.  *
  22.  * Contributor(s):
  23.  *   Dean Tessman <dean_tessman@hotmail.com>
  24.  *
  25.  * Alternatively, the contents of this file may be used under the terms of
  26.  * either of the GNU General Public License Version 2 or later (the "GPL"),
  27.  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  28.  * in which case the provisions of the GPL or the LGPL are applicable instead
  29.  * of those above. If you wish to allow use of your version of this file only
  30.  * under the terms of either the GPL or the LGPL, and not to allow others to
  31.  * use your version of this file under the terms of the MPL, indicate your
  32.  * decision by deleting the provisions above and replace them with the notice
  33.  * and other provisions required by the GPL or the LGPL. If you do not delete
  34.  * the provisions above, a recipient may use your version of this file under
  35.  * the terms of any one of the MPL, the GPL or the LGPL.
  36.  *
  37.  * ***** END LICENSE BLOCK ***** */
  38.  
  39. #ifndef nsIMenuParent_h___
  40. #define nsIMenuParent_h___
  41.  
  42.  
  43. // {81C0BF71-9F50-4f4d-8B6A-D6B233C100C2}
  44. #define NS_IMENUPARENT_IID \
  45. { 0x81c0bf71, 0x9f50, 0x4f4d, { 0x8b, 0x6a, 0xd6, 0xb2, 0x33, 0xc1, 0x0, 0xc2 } };
  46.  
  47. class nsIMenuFrame;
  48. class nsIDOMKeyEvent;
  49.  
  50. /*
  51.  * nsIMenuParent is implemented on frames and thus should not be
  52.  * refcounted.  Eventually it should not inherit from nsISupports.
  53.  */
  54.  
  55. /**
  56.  * nsNavigationDirection: an enum expressing navigation through the menus in
  57.  * terms which are independent of the directionality of the chrome. The
  58.  * terminology, derived from XSL-FO and CSS3 (e.g. 
  59.  * http://www.w3.org/TR/css3-text/#TextLayout), is BASE (Before, After, Start,
  60.  * End), with the addition of First and Last (mapped to Home and End
  61.  * respectively).
  62.  *
  63.  * In languages such as English where the inline progression is left-to-right
  64.  * and the block progression is top-to-bottom (lr-tb), these terms will map out
  65.  * as in the following diagram
  66.  *
  67.  *  --- inline progression --->
  68.  *
  69.  *           First              |
  70.  *           ...                |
  71.  *           Before             |
  72.  *         +--------+         block
  73.  *   Start |        | End  progression
  74.  *         +--------+           |
  75.  *           After              |
  76.  *           ...                |
  77.  *           Last               V
  78.  * 
  79.  */
  80.  
  81. enum nsNavigationDirection {
  82.   eNavigationDirection_Last,
  83.   eNavigationDirection_First,
  84.   eNavigationDirection_Start,
  85.   eNavigationDirection_Before,
  86.   eNavigationDirection_End,
  87.   eNavigationDirection_After
  88. };
  89.  
  90. #define NS_DIRECTION_IS_INLINE(dir) (dir == eNavigationDirection_Start ||     \
  91.                                      dir == eNavigationDirection_End)
  92. #define NS_DIRECTION_IS_BLOCK(dir) (dir == eNavigationDirection_Before || \
  93.                                     dir == eNavigationDirection_After)
  94. #define NS_DIRECTION_IS_BLOCK_TO_EDGE(dir) (dir == eNavigationDirection_First ||    \
  95.                                             dir == eNavigationDirection_Last)
  96.  
  97. /**
  98.  * DirectionFromKeyCode_lr_tb: an array that maps keycodes to values of
  99.  * nsNavigationDirection for left-to-right and top-to-bottom flow orientation
  100.  */
  101. static nsNavigationDirection DirectionFromKeyCode_lr_tb [6] = {
  102.   eNavigationDirection_Last,   // NS_VK_END
  103.   eNavigationDirection_First,  // NS_VK_HOME
  104.   eNavigationDirection_Start,  // NS_VK_LEFT
  105.   eNavigationDirection_Before, // NS_VK_UP
  106.   eNavigationDirection_End,    // NS_VK_RIGHT
  107.   eNavigationDirection_After   // NS_VK_DOWN
  108. };
  109.  
  110. /**
  111.  * DirectionFromKeyCode_rl_tb: an array that maps keycodes to values of
  112.  * nsNavigationDirection for right-to-left and top-to-bottom flow orientation
  113.  */
  114. static nsNavigationDirection DirectionFromKeyCode_rl_tb [6] = {
  115.   eNavigationDirection_Last,   // NS_VK_END
  116.   eNavigationDirection_First,  // NS_VK_HOME
  117.   eNavigationDirection_End,    // NS_VK_LEFT
  118.   eNavigationDirection_Before, // NS_VK_UP
  119.   eNavigationDirection_Start,  // NS_VK_RIGHT
  120.   eNavigationDirection_After   // NS_VK_DOWN
  121. };
  122.  
  123. #ifdef IBMBIDI
  124. #define NS_DIRECTION_FROM_KEY_CODE(direction, keycode)           \
  125.   NS_ASSERTION(keycode >= NS_VK_END && keycode <= NS_VK_DOWN,    \
  126.                "Illegal key code");                              \
  127.   const nsStyleVisibility* vis = GetStyleVisibility();           \
  128.   if (vis->mDirection == NS_STYLE_DIRECTION_RTL)                 \
  129.     direction = DirectionFromKeyCode_rl_tb[keycode - NS_VK_END]; \
  130.   else                                                           \
  131.     direction = DirectionFromKeyCode_lr_tb[keycode - NS_VK_END];
  132. #else
  133. #define NS_DIRECTION_FROM_KEY_CODE(direction, keycode)           \
  134.     direction = DirectionFromKeyCode_lr_tb[keycode - NS_VK_END];
  135. #endif
  136.  
  137. class nsIMenuParent : public nsISupports {
  138.  
  139. public:
  140.   NS_DEFINE_STATIC_IID_ACCESSOR(NS_IMENUPARENT_IID)
  141.  
  142.   virtual nsIMenuFrame *GetCurrentMenuItem() = 0;
  143.   NS_IMETHOD SetCurrentMenuItem(nsIMenuFrame* aMenuItem) = 0;
  144.   virtual nsIMenuFrame *GetNextMenuItem(nsIMenuFrame* aStart) = 0;
  145.   virtual nsIMenuFrame *GetPreviousMenuItem(nsIMenuFrame* aStart) = 0;
  146.  
  147.   NS_IMETHOD SetActive(PRBool aActiveFlag) = 0;
  148.   NS_IMETHOD GetIsActive(PRBool& isActive) = 0;
  149.   NS_IMETHOD GetWidget(nsIWidget **aWidget) = 0;
  150.   
  151.   NS_IMETHOD IsMenuBar(PRBool& isMenuBar) = 0;
  152.   NS_IMETHOD ConsumeOutsideClicks(PRBool& aConsumeOutsideClicks) = 0;
  153.   NS_IMETHOD ClearRecentlyRolledUp() = 0;
  154.   NS_IMETHOD RecentlyRolledUp(nsIMenuFrame *aMenuFrame, PRBool *aJustRolledUp) = 0;
  155.  
  156.   NS_IMETHOD DismissChain() = 0;
  157.   NS_IMETHOD HideChain() = 0;
  158.   NS_IMETHOD KillPendingTimers() = 0;
  159.  
  160.   NS_IMETHOD CreateDismissalListener() = 0;
  161.  
  162.   NS_IMETHOD InstallKeyboardNavigator() = 0;
  163.   NS_IMETHOD RemoveKeyboardNavigator() = 0;
  164.  
  165.   // Used to move up, down, left, and right in menus.
  166.   NS_IMETHOD KeyboardNavigation(PRUint32 aKeyCode, PRBool& aHandledFlag) = 0;
  167.   NS_IMETHOD ShortcutNavigation(nsIDOMKeyEvent* aKeyEvent, PRBool& aHandledFlag) = 0;
  168.   // Called when the ESC key is held down to close levels of menus.
  169.   NS_IMETHOD Escape(PRBool& aHandledFlag) = 0;
  170.   // Called to execute a menu item.
  171.   NS_IMETHOD Enter() = 0;
  172.  
  173.   NS_IMETHOD SetIsContextMenu(PRBool aIsContextMenu) = 0;
  174.   NS_IMETHOD GetIsContextMenu(PRBool& aIsContextMenu) = 0;
  175.   
  176. };
  177.  
  178. #endif
  179.  
  180.